package com.gzr.validation;

import com.gzr.anno.State;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

public class StateValidation implements ConstraintValidator<State, String> {

    /**
     * 校验规则
     * @param s 入参
     * @param constraintValidatorContext
     * @return true 校验成功 false 校验失败
     */
    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
        //提供校验规则
        if (s == null){
            return false;
        }

        if ("已发布".equals(s) || "草稿".equals(s)) {
            return true;
        }
        return false;
    }
}
